你需要替换掉 huanf-xue-media/xue-media-api/src/main/java/com/huanf/media/api/MediaFilesController.java

package com.huanf.media.api;

import com.huanf.base.enums.CourseEnum;
import com.huanf.base.model.PageParams;
import com.huanf.base.model.PageResult;
import com.huanf.base.model.RestResponse;
import com.huanf.domain.dto.UploadFileParamsDto;
import com.huanf.domain.dto.UploadFileResultDto;
import com.huanf.media.service.MediaFilesService;
import com.huanf.domain.dto.QueryMediaParamsDto;
import com.huanf.domain.entity.MediaFiles;
import com.huanf.media.util.SecurityUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

/**
 * @author: 35238
 * 功能: 媒资文件管理
 * 时间: 2024-04-15 22:09
 */
@Api(value = "媒资文件管理接口",tags = "媒资文件管理接口")
@RestController
public class MediaFilesController {

    @Value("${minio.endpoint}")
    private String endpoint;

    @Autowired
    MediaFilesService mediaFileService;


    @DeleteMapping("{id}")
    public RestResponse del(@PathVariable String id) {
        mediaFileService.removeById(id);
        return RestResponse.success();
    }

    @GetMapping("/preview/{mediaId}")
    public RestResponse<String> getPlayUrlByMediaId(@PathVariable String mediaId){

        MediaFiles mediaFiles = mediaFileService.getFileById(mediaId);
        if(mediaFiles == null || StringUtils.isEmpty(mediaFiles.getUrl())){
            return RestResponse.validfail("该视频上传有误，请重新上传");
        }
        return RestResponse.success(endpoint+mediaFiles.getUrl());
    }

    @ApiOperation("媒资列表查询接口")
    @PostMapping("/files")
    public PageResult<MediaFiles> list(PageParams pageParams, @RequestBody QueryMediaParamsDto queryMediaParamsDto){
        SecurityUtil.XcUser user = SecurityUtil.getUser();
        Long companyId = Long.valueOf(user.getId());
        return mediaFileService.queryMediaFiels(companyId,pageParams,queryMediaParamsDto);
    }

    @ApiOperation("媒资列表查询接口")
    @PostMapping("/files2")
    public PageResult<MediaFiles> list2(PageParams pageParams, @RequestBody QueryMediaParamsDto queryMediaParamsDto){
        SecurityUtil.XcUser user = SecurityUtil.getUser();
        Long companyId = Long.valueOf(user.getId());
        return mediaFileService.queryMediaFiels2(companyId,pageParams,queryMediaParamsDto);
    }

    //------------------------------------整合minio-上传图片--------------------------------------

    @ApiOperation("上传图片文件")
    @PostMapping(value = "/upload/coursefile",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @ResponseBody
    public UploadFileResultDto upload(@RequestPart("filedata") MultipartFile filedata,
                                      @RequestParam(value= "objectName", required = false) String objectName) throws IOException {

        Long companyId = 123456L;//这个是xxl-job调用的，不是由用户去调用，所以拿不到真实companyId，就写死是123456了
        UploadFileParamsDto uploadFileParamsDto = new UploadFileParamsDto();
        //文件大小
        uploadFileParamsDto.setFileSize(filedata.getSize());
        //图片类型
        uploadFileParamsDto.setFileType(CourseEnum.MINIO_TYPE_IMG.getCode());
        //文件名称
        uploadFileParamsDto.setFilename(filedata.getOriginalFilename());//文件名称
        //文件大小
        long fileSize = filedata.getSize();
        uploadFileParamsDto.setFileSize(fileSize);
        //创建临时文件，这个临时文件会在服务器
        File tempFile = File.createTempFile("minio", "temp");//临时文件，前缀+后缀，随便写都可以
        //用户上传的文件拷贝到临时文件。也就是把用户上传的文件，保存到服务器中
        filedata.transferTo(tempFile);
        //从临时文件获取文件路径
        String absolutePath = tempFile.getAbsolutePath();
        //上传文件到Minio
        UploadFileResultDto uploadFileResultDto = mediaFileService.uploadFile(companyId, uploadFileParamsDto, absolutePath, objectName);

        return uploadFileResultDto;
    }

}
